package com.wmh.baseservice.operationaid.pojo.vo.productTrafficSource;

import com.wmh.baseservice.operationaid.entity.ProductTrafficSource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author 谢骏
 * @date 2023/7/23 13:50
 **/
@Data
@Accessors(chain = true)
@ApiModel(value = "机器提交参数请求体")
public class ProductTrafficSourceRobotCommitReqVO {

    /**
     * 店铺名称
     * */
    @ApiModelProperty("店铺名称")
    @NotBlank(message = "未提交店铺名称")
    private String storeName;


    /**
     * 数据周期
     * */
    @ApiModelProperty("数据周期")
    @NotBlank(message = "未提交数据周期")
    private String dataCycle;

    /**
     * 商品标题
     * */
    @ApiModelProperty("商品标题")
    @NotBlank(message = "未提交商品标题")
    private String productTitle;

    /**
     * 商品编号
     * */
    @ApiModelProperty("商品编号")
    @NotNull(message = "未提交商品编号")
    private Long productId;

    /**
     * 指数字段封装即 列表元素 {@link ExponentialField}
     * */
    @ApiModelProperty("指数字段列表的 json 格式字符串")
    @NotBlank(message = "未提交商品指数列表")
    @Size(min= 3,message = "未提交商品指数列表")
    private String exponentialFieldListJson;

    public static ProductTrafficSource buildEntity(ProductTrafficSourceRobotCommitReqVO reqVO,ExponentialField exponentialField){
        ProductTrafficSource r = new ProductTrafficSource();
        r.setStoreName(reqVO.getStoreName());
        r.setTrafficsSource(exponentialField.getTrafficsSource());
        r.setDataCycle(reqVO.getDataCycle());
        r.setProductTitle(reqVO.getProductTitle());
        r.setProductId(reqVO.getProductId());
        r.setVisitorNum(exponentialField.getVisitorNum());
        r.setBuyersNum(exponentialField.getBuyersNum());
        r.setOrderCvsRate(exponentialField.getOrderCvsRate());
        r.setPageView(exponentialField.getPageView());
        r.setPercentageOfPageViews(exponentialField.getPercentageOfPageViews());
        r.setInStoreJump(exponentialField.getInStoreJump());
        r.setOutStoreJump(exponentialField.getInStoreJump());
        r.setCollectorNum(exponentialField.getCollectorNum());
        r.setCollectionRate(exponentialField.getCollectionRate());
        r.setAdditionalPurchase(exponentialField.getAdditionalPurchase());
        r.setAdditionRate(exponentialField.getAdditionRate());
        r.setPayoutsNum(exponentialField.getPayoutsNum());
        r.setPaidBuyersNum(exponentialField.getPaidBuyersNum());
        r.setAmountPaid(exponentialField.getAmountPaid());
        r.setPayCvsRate(exponentialField.getPayCvsRate());
        r.setDirectPayBuyersNum(exponentialField.getDirectPayBuyersNum());
        r.setPayAfterCollectionBuyersNum(exponentialField.getPayAfterCollectionBuyersNum());
        r.setPayAfterAttentionBuyersNum(exponentialField.getPayAfterAttentionBuyersNum());
        r.setBuyMoreBuyersNum(exponentialField.getBuyMoreBuyersNum());
        r.setPerCustomer(exponentialField.getPerCustomer());
        r.setUvValue(exponentialField.getUvValue());
        return r;
    }
}
